<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'home';
$return['ischecklogin']=cfc('core')->checklogin('','',true);
$this->model('member')->upmember();
$return['pluginset']['ailogo']=tomedia($return['pluginset']['ailogo']);
$return['basic']=$return['pluginset'];
if($_RQ['op']=='home'){
	if($_RQ['chatid']){
		$return['chat']=pdo_get('jy_aiagent_useragentlog',array('id'=>$_RQ['chatid'],'uniacid'=>$_SESSION['uniacid']));
	}else{
		exi('请选择设备进入！','error');
	}
	$return['llm_models']=$this->llm_models;
	$return['llm_models2']=array();
	$index=0;
	foreach($return['llm_models'] as $k=>$title){
		if($k==$return['chat']['model']){
			$return['chat']['model2']=$index;
		}
		$index++;
		$return['llm_models2'][]=array('id'=>$k,'title'=>$title);
	}
	$return['yuyuantypes']=$this->yuyuantypes;
	$return['chat']['llm_modeltitle']=$this->llm_models[$return['chat']['model']];
	$return['params']=array('chatid'=>$_RQ['chatid'],'voicesex'=>0,'yuyuantype'=>0);
	$return['sharedata']=array(
		'title'=>$return['goods']['title'],
		'desc'=>$return['basic']['share_desc'],
		'link'=>custom_url('jy_aiagent/index//fromuser='.$_SESSION['uid'],true),
		'imgUrl'=>$return['post']['logo'],
	);
	set_html('title',$return['chat']['title']);
	exi($return);
}
if($_RQ['op']=='getlist'){
	$chatid=$_RQ['chatid'];
	$params=array('uniacid'=>$_SESSION['uniacid'],'chatid'=>$chatid);
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$_RQ['page'] = $_RQ['page'] ? $_RQ['page'] : 1;
	$pindex = max(1, intval($_RQ['page']));
	if(intval($_RQ['num'])){
		$psize = intval($_RQ['num']);
	}else{
		$psize = 20;
	}
	$total='';
	$list=pdo_getslice('jy_aiagent_useragentlogitem',$params,array($pindex,$psize),$total,$fields,'','id asc');
	foreach($list as &$item){
		$item['createtime']=date('Y/m/d H:i:s',$item['createtime']);
	}
	$return['list']=$list;
	exi($return);
}